import { UIStateEvent } from "../events"
import { Controller } from "./types"

/**
 * 画布大小变化处理器
 */
export class ResizeHandler extends Controller {
  handler = ({ detail, renderer }: UIStateEvent) => {
    renderer.composer.setSize(detail.width, detail.height)
    renderer.renderer.setSize(detail.width, detail.height, false)
    renderer.camera.aspect = detail.width / detail.height
    renderer.camera.updateProjectionMatrix()
  }
}
